package nl.mikoosoft.sport.stoer.domain;

import org.hibernate.validator.constraints.NotBlank;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.serializable.RooSerializable;
import org.springframework.roo.addon.tostring.RooToString;
import java.util.Calendar;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Size;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Set;
import nl.mikoosoft.sport.stoer.domain.Division;
import java.util.HashSet;
import javax.persistence.OneToMany;
import javax.persistence.CascadeType;
import nl.mikoosoft.sport.stoer.domain.Account;
import javax.validation.constraints.NotNull;
import javax.persistence.ManyToOne;

@RooJavaBean
@RooToString
@RooEntity(identifierColumn = "tournamentId", versionColumn = "revision")
@RooSerializable
public class Tournament {

    /**
	 * 
	 */
    private static final long serialVersionUID = 1959362880390057422L;

    @NotBlank
    @Size(max = 64, min = 3)
    private String name;

    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(style = "MS")
    private Calendar startDateTime;

    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(style = "MS")
    private Calendar endDateTime;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tournament")
    private Set<Division> divisions = new HashSet<Division>();

    @NotNull
    @ManyToOne
    private Account owner;
}
